package thread3;

public class Test6 {
    private static Object object = new Object();

    public static void main(String[] args) throws InterruptedException {
        Thread waiter = new Thread(() -> {
            while (true) {
                synchronized (object) {
                    System.out.println("wait 开始");
                    try {
                        object.wait();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println("wait 结束");
                }
            }
        });
        waiter.start();

        Thread.sleep(3000);

        Thread notifier = new Thread(() -> {
            synchronized (object) {
                System.out.println("notify 之前");
                object.notify();
                System.out.println("notify 之后");
            }
        });
        notifier.start();
    }
}
